package org.example.controller;

import org.example.pojo.Response;
import org.example.pojo.Result;
import org.example.utils.AliOSSUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/upload")
public class UploadController {

    @Autowired
    AliOSSUtils aliOSSUtils;

    @PostMapping("/upload")
    public Result upload(MultipartFile file) throws IOException {
        String url = aliOSSUtils.uploadFile(file,"");
        return Result.success(url);
    }
    @PostMapping("/image")
    public Response uploadImage(MultipartFile file) throws IOException {
        String url = aliOSSUtils.uploadFile(file,"article/image/");
        return Response.success(url);
    }
}
